<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>题目管理</title>
    <meta name="decorator" content="default"/>
   
    <%@include file="/WEB-INF/views/include/treetable.jsp" %>
    <script type="text/javascript">
        $(document).ready(function () {

            load();

        });
        function load() {
            var tpl = $("#treeTableTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
            var data = ${fns:toJson(list)}, rootId = "0";
            
            
            addRow("#treeTableList", tpl, data, rootId, true);
            $("#treeTable").treeTable({expandLevel : 1});
            
            
            
        };
        
        function addRow(list, tpl, data, pid, root){
            for (var i=0; i<data.length; i++){
                var row = data[i];
                
                var display='none';
                  
                var displayQ='none';
                
                if(row.answerId){
                
                    display='incline';
                    
                }else{
                	
                	displayQ='incline';
                }
                
                if ((${fns:jsGetVal('row.pId')}) == pid){
                    $(list).append(Mustache.render(tpl, {
                         pid: (root?0:pid), row: row,display:display,displayQ:displayQ
                         
                    })); 
                    addRow(list, tpl, data, row.id);
                }

            }
        }
        

    </script>
</head>
<body>
    <ul class="nav nav-tabs">
        <%--<li class="active"><a href="${ctx}/question/beautyConsultationOrderQuestion/">题目列表</a></li>--%>
        <li><a href="${ctx}/consultation/">咨询列表</a></li>
        
    </ul>
    <form:form id="searchForm" modelAttribute="beautyConsultationOrderQuestion" action="${ctx}/consultation/question/questionList?orderId=${orderId}" method="post" class="breadcrumb form-search">
        <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
        <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
        <ul class="ul-form">

            <li><label>题目：</label>
                <form:input path="questionTitle" htmlEscape="false" maxlength="255" class="input-medium"/>
                
            </li>
            <li><label>答案类型：</label>
                <form:select path="answerType" class="input-xlarge">
                    <option value="">请选择</option>
                    <form:options items="${fns:getAnswerTypeList()}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                </form:select>
            </li>

            <li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>

            <li class="clearfix"></li>
        </ul>
    </form:form>
    <sys:message content="${message}"/>

    
    
    <table id="treeTable" class="table table-striped table-bordered table-condensed">
        <th>问答</th>
        <th>序号</th>
        <th>主图</th>
        <th>答案类型</th>
        <th>操作</th>        
    <tbody id="treeTableList"></tbody>
    </table>
    <script type="text/template" id="treeTableTpl">
        <tr id="{{row.id}}" pId="{{pid}}">
            <td style="display:{{displayQ}}">{{row.answerTitle}}({{row.remarks}})</td>
            <td style="display:{{display}}"><a href="${ctx}/consultation/answer/form?id={{row.answerId}}">{{row.answerTitle}}</a></td>

            <td>{{row.questionNo}}</td>
            <td  style="display:{{displayQ}}" ><img src="{{row.questionImage}}"  alt="主图预览" style="height:30px;weight:30px" /></td>
            <td   style="display:{{display}}" ><img src="{{row.answerImage}}"  alt="未上传" style="height:30px;weight:30px" /></td>
            <td>{{row.answerTypeName}}</td>
            <td>
                <a href="${ctx}/consultation/recommend/form?answerId={{row.answerId}}&&orderId={{row.orderId}}" style="display:{{display}}">设置诊断推荐</a>
                <a href="${ctx}/consultation/question/form?id={{row.id}}" style="display:{{displayQ}}">修改图片</a>
                <a href="${ctx}/consultation/answer/modifyForm?id={{row.answerId}}" style="display:{{display}}">答案修改</a>                
            </td>
        </tr>
    </script>
    <div class="pagination">${page}</div>
</body>
</html>